public class Main {

    public static void main(String[] args) {

        int[] arr = {9,2,1,6,4,8,7,3,5,76,34};
        QuickSort.sort(arr,0,arr.length-1);
        for (int a: arr) {
            System.out.print(a+ " ");
        }
    }
}

class QuickSort {

    public static void sort(int[] arr, int low, int high) {

        if (low < high) {
            // split into two
            int pivokey = partition(arr, low, high);
            // sort the two part
            // recursive call func of sort
            sort(arr, low, pivokey-1);
            sort(arr, pivokey+1, high);
        }

    }

    private static int partition(int[] arr, int low, int high) {

        // select first num as the povikey
        int pivokey = arr[low];
        do {
            // find from end
            while (low < high && arr[high] > pivokey )
                high--;
            arr[low] = arr[high];

            // find from front
            while (low < high && arr[low] < pivokey)
                low++;
            arr[high] = arr[low];
        }while(low < high);

        //
        arr[low] = pivokey;
        return low;
    }
}